package main
import (
	"fmt"
	_ "unsafe"
	"strconv"
)
func main(){

	var num = 10.11
	fmt.Println("num = ",num)

	var name = "tom"
	fmt.Println(name)

	//基本数据类型转String
	var num1 int = 99
	var num2 float64 = 233.23
	var b bool = true
	var mychar byte = 'h'
	var str string //空的str

	//使用 fmt.Sprintf 方法
	str = fmt.Sprintf("%d", num1)
	fmt.Printf("str type %T str = %v\n", str , str)

	str = fmt.Sprintf("%f", num2)
	fmt.Printf("str type %T str = %v\n", str , str)

	str = fmt.Sprintf("%t", b)
	fmt.Printf("str type %T str = %q\n", str , str)

	str = fmt.Sprintf("%c", mychar)
	fmt.Printf("str type %T str = %q\n", str , str)

	//第二种 strconv 函数
	var num3 int = 88
	var num4 float64 = 455.88
	var b2 bool = true

	str = strconv.FormatInt(int64(num3), 10)
	fmt.Printf("str type %T str = %q\n", str , str)

	str = strconv.FormatFloat(num4, 'f', 10, 64)
	fmt.Printf("str type %T str = %q\n", str , str)

	str = strconv.FormatBool(b2)
	fmt.Printf("str type %T str = %q\n", str , str)
}